package com.jfzt.common;

import lombok.Getter;

/**
 * 枚举结果值
 * @author: shunpeng.hu
 * @date: 2024/3/7 15:21
 */
@Getter
public enum ResultBusinessTypeEnum {

    //1. 举值
    INSETT("1001", "增加"),

    DELETE("1002", "删除"),

    UPDATE("1003","修改"),

    SELECT("1004", "查询"),

    success("200", "成功"),

    REDIRECTE("300", "重定向"),

    UNAUTHORIZED("401", "未授权"),

    CLIENTCANNOTACCESS("404", "客户端无法访问"),

    SERVERERROR("500", "服务器错误");

    //2. 构造
    public final String code;

    private final String message;

    ResultBusinessTypeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    //3. 遍历
    public static ResultBusinessTypeEnum getBusinessTypeEnum(String code){
        for (ResultBusinessTypeEnum element : ResultBusinessTypeEnum.values()) {
            if (element.getCode().equalsIgnoreCase(code)) {
                return element;
            }
        }
        return null;
    }

}
